package pers.vic.test.config.thymeleaf;

import org.apache.commons.text.StringEscapeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import pers.vic.test.thymeleaf.XssStringFormatter;

/**
 * 描述:
 * @author Vic.xu
 * @date 2022-03-21 10:50
 */
@Configuration
public class ThymeleafFormatter {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Bean
    public XssStringFormatter xssStringFormatter() {
        logger.info("register XssStringFormatter");
        return new XssStringFormatter();
    }

    public static void main(String[] args) {
        String a = "<script>alert('asd');</script>";
        System.out.println(StringEscapeUtils.escapeHtml4(a));
    }
}
